﻿using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class BreedEnterpriseService : IBreedEnterpriseService
    {
        private readonly IBreedEnterpriseRepository _BreedEnterpriserepository;
        public BreedEnterpriseService(IBreedEnterpriseRepository BreedEnterpriserepository)
        {
           _BreedEnterpriserepository = BreedEnterpriserepository;
        }
        /// <summary>
        /// 添加养殖企业
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        public async Task<int> AddBreedEnterprise(BreedEnterprise breedEnterprise)
        {
           return await _BreedEnterpriserepository.AddAsync(breedEnterprise);
        }
        /// <summary>
        /// 显示养殖企业
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        public async Task<List<BreedEnterprise>> GetBreedEnterprise(string bath)
        {
           var listobj=from a in await _BreedEnterpriserepository.GetAllAsync()
                       where !a.IsDel&&a.Batch==bath
                       select a;
            return listobj.ToList();
        }
        /// <summary>
        /// 修改养殖企业
        /// </summary>
        /// <param name="breedEnterprise"></param>
        /// <returns></returns>
        public async Task<int> UpdateBreedEnterprise(BreedEnterprise breedEnterprise)
        {
           return await _BreedEnterpriserepository.UpdateAsync(breedEnterprise);
        }
    }
}
